package com.kefu.call.controller;

import com.kefu.call.model.CallMakeCall;
import com.kefu.call.model.CallStart;
import com.kefu.call.service.CallTagRelService;
import com.kefu.call.vo.CallTagRelInsertVo;
import com.kefu.common.controller.AbstractBaseController;
import com.kefu.common.result.Result;
import com.kefu.common.result.ResultGenerator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags = "通话标签")
@RestController
@RequestMapping("call/tag/")
public class CallTagRelController extends AbstractBaseController {

    @Resource
    private CallTagRelService callTagRelService;

    @PostMapping("/in/add")
    @ApiOperation(value = "添加呼入通话标签", notes = "添加呼入通话标签")
    public Result<CallStart> inAdd(@Validated @RequestBody CallTagRelInsertVo callTagRelVo) {
    	logger.info("添加呼入通话标签:{}", callTagRelVo);

        CallStart callStart = callTagRelService.addInTag(callTagRelVo);
        return ResultGenerator.genSuccessResult(callStart);
    }

    @PostMapping("/out/add")
    @ApiOperation(value = "添加呼出通话标签", notes = "添加呼出通话标签")
    public Result<CallMakeCall> outAdd(@Validated @RequestBody CallTagRelInsertVo callTagRelVo) {
        logger.info("添加呼出通话标签:{}", callTagRelVo);

        CallMakeCall callMakeCall = callTagRelService.addOutTag(callTagRelVo);
        return ResultGenerator.genSuccessResult(callMakeCall);
    }
}
